package com.lanqiao.pet.entity;

public abstract class Pet {
    //属性（成员变量）
    private String name;
    private int age;
    private String kind;
    private double price;

    public Pet(String kind) {
        this.kind = kind;
    }

    //成员方法
    public void eat(String food) {
        System.out.println(name + "在吃" + food);
    }

    public void sleep() {
        System.out.println(name + "在睡觉");
    }

    public abstract String bark();

    //getter & setter

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age > 15 || age < 0) {
            System.out.println("年龄输入错误！");
        } else {
            this.age = age;
        }

    }

    public String getKind() {
        return kind;
    }

    @Override
    public String toString() {
        return "Pet{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", kind='" + kind + '\'' +
                ", price=" + price +
                '}';
    }
}
